<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="ISO-8859-1"/>

<xsl:template match="PLANETES">
<DOCUMENT>
    <TITRE>
        Les plantes
    </TITRE>
    <PLANETES>
        Les trois premires plantes sont: <xsl:apply-templates select="PLANETE"/>
    </PLANETES>
</DOCUMENT>
</xsl:template>

<xsl:template match="PLANETE">
    <xsl:if test="NOM[not(text())]">
        <xsl:message terminate="yes">
            Chaque plante doit avoir un nom!
        </xsl:message>
    </xsl:if>
    <xsl:value-of select="NOM"/>
    <xsl:choose>
        <xsl:when test="position()!=last()">, </xsl:when>
        <xsl:when test="position()=last()-1">et </xsl:when>
        <xsl:otherwise>.</xsl:otherwise>
    </xsl:choose>
</xsl:template>
    
</xsl:stylesheet>
